package com.tqz.rc.client.naming;

import java.lang.reflect.Constructor;
import java.util.Properties;

/**
 * <p>命名空间的的工厂。
 *
 * @author tianqingzhao
 * @since 2021/9/2 16:19
 */
public class NamingFactory {

    /**
     * 反射创建 {@link NamingService} 的实例。
     *
     * @param properties 配置属性
     * @return
     * @throws Exception
     */
    public static NamingService createNamingService(Properties properties) throws Exception {
        try {
            Class<?> driverImplClass = Class.forName("com.tqz.rc.client.naming.NacosNamingService");
            Constructor<?> constructor = driverImplClass.getConstructor(Properties.class);
            return (NamingService) constructor.newInstance(properties);
        } catch (Exception e) {
            throw new Exception(e);
        }
    }


}
